    ;first make sure the number of arguments passed into the scripts is more than 1 ;
If $CmdLine[0]<2 Then 
  Exit 
EndIf
handleUpload($CmdLine[1],$CmdLine[2])        ; define a function to handle upload
Func handleUpload($browser, $uploadfile)
	 Dim $title                             ;declare a variable;specify the upload window title according to the browser;
            If $browser="IE" Then         ;stands for IE;
 	       $title="Choose File to Upload"
	        If WinWait($title,"",1) Then   ;wait for window with title attribute for 1 second;
			WinActivate($title)                                   ;active the window;
			ControlSetText($title,"","Edit1",$uploadfile)   ;put the file path into the textfield  ;
			ControlClick($title,"","Button1")                   ;click the OK or Save button;
			;WinClose($title)
		Else
			Exit
		EndIf
            Else    
		 If $browser="Firefox" Then
			$title="File Upload"	 ; stands for Firefox
			If WinWait($title,"",1) Then
				WinActive($title)
				ControlSetText($title,"","Edit1",$uploadfile) 
				ControlClick($title,"","Button1")
			Else
				Exit
			EndIf	
		EndIf	
            EndIf
 
           
 EndFunc 
